﻿using System.Collections.Generic;
using System.Xml.Linq;

namespace XSerialization.Generator
{
    /// <summary>
    /// XSD File Informations
    /// </summary>
    public interface IXsdDocument
    {
        /// <summary>
        /// Loaded XSD File
        /// </summary>
        XDocument XsdFile { get; set; }

        /// <summary>
        /// List of all defined complex Types
        /// </summary>
        Dictionary<string, XsdComplexType> ComplexTypes { get; set; }

        /// <summary>
        /// List of all defined simple Types
        /// </summary>
        Dictionary<string, XsdSimpleType> SimpleTypes { get; set; }

        /// <summary>
        /// List of all defined enumeration Types
        /// </summary>
        Dictionary<string, XsdEnumerationType> EnumerationTypes { get; set; }

        /// <summary>
        /// List of all defined NameSpaces
        /// </summary>
        Dictionary<string, string> NameSpaces { get; set; }

        /// <summary>
        /// Generated Class Code
        /// </summary>
        string ClassCode { get; set; }

        /// <summary>
        /// Generated Interface Code
        /// </summary>
        string InterfaceCode { get; set; }
    }

    /// <summary>
    /// XSD File Informations
    /// </summary>
    public class XsdDocument : IXsdDocument
    {
        /// <summary>
        /// Loaded XSD File
        /// </summary>
        public XDocument XsdFile { get; set; }

        /// <summary>
        /// List of all defined complex Types
        /// </summary>
        public Dictionary<string, XsdComplexType> ComplexTypes { get; set; }

        /// <summary>
        /// List of all defined simple Types
        /// </summary>
        public Dictionary<string, XsdSimpleType> SimpleTypes { get; set; }

        /// <summary>
        /// List of all defined enumeration Types
        /// </summary>
        public Dictionary<string, XsdEnumerationType> EnumerationTypes { get; set; }

        /// <summary>
        /// List of all defined NameSpaces
        /// </summary>
        public Dictionary<string, string> NameSpaces { get; set; }

        /// <summary>
        /// Generated Class Code
        /// </summary>
        public string ClassCode { get; set; }

        /// <summary>
        /// Generated Interface Code
        /// </summary>
        public string InterfaceCode { get; set; }

        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="xsdfile">XSD File</param>
        public XsdDocument(XDocument xsdfile)
        {
            XsdFile = xsdfile;
            ComplexTypes = new Dictionary<string, XsdComplexType>();
            SimpleTypes = new Dictionary<string, XsdSimpleType>();
            EnumerationTypes = new Dictionary<string, XsdEnumerationType>();
            NameSpaces = new Dictionary<string, string>();
        }
    }
}
